<?php
	include('include/configs.inc.php');

	if(!empty($_POST['token'])) {
		$nom = $_POST['nom'];
		$prenom = $_POST['prenom'];
		$email = $_POST['email'];
		$adresse = $_POST['adresse'];
		$ville = $_POST['ville'];
		$pays = $_POST['pays'];
		$code = $_POST['code'];
		$password = $_POST['password'];
		$confirmation = $_POST['confirmation'];
		$error = '';
		
		if($password != $confirmation) {
			$error = "Le mot de passe et la confirmation sont diff&eacute;rents !";
		}
		
		if(empty($nom) || empty($prenom) || empty($email) || empty($password) || empty($confirmation)) {
			$error .= "<br/>Tout les champs sont obligatoires, merci de tous les remplir !";
		}
		
		if($error == '') {
			$sql = "INSERT INTO user VALUES('', '".$nom."', '".$prenom."', '".$adresse."', '".$code."', '".$ville."', '".$pays."', '".$email."', SHA1('".$password."'), '1')";
			
			if($connect->query($sql)) {
				$message = "Vous &ecirc;tes maintenant enregsitr&eacute; !";
			} else {
				echo $error = $connect->error;
			}
		}
	}
	
	include('template/Site_inscription.html');
?>